﻿<extend name="Public:office" />
<block name="title"><title>成员管理</title></block>
<block name="header_styles">
    <style type="text/css">
        .main-wrapper .container {
            background-color: #ffffff;
        }

        .dropdown-menu {
            text-align: center;
        }
    </style>
</block>
<block name="main">
    <div class="tabs-wrapper">
        <include file="Team:menu" />
        <div class="tab-content">
            <div class="tab-pane active" style="min-height: 600px;">
                <div class="columns">
                    <div class="column-left">
                        <p>团队成员</p>
                        <ul class="vertical-navigation">
                            <volist name='roles' id='role'>
                                <li class="roleitem"><a href="#" id="t_{$role.id}" class="tab-link">{$role.nickname}</a></li>
                            </volist>
                        </ul>
                    </div>
                    <div id="authconfig" class="column-right">

                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="footer_scripts">
    <script type="text/javascript">
    require(["jquery","modules/message"], function ($,messageBox) {
        $("#authconfig").on("click", ".saveAuthconfig", function () {
            var roleid = $(this).data("roleid");
            var url = "{:U('/Team/saveroleauth_ajax')}";
            var checkedAuthes = new Array();
            $("input[type=checkbox][name='auth[]']:checked").each(function () {
                checkedAuthes.push($(this).val());
            });
            $.post(url, { roleid: roleid, choose: checkedAuthes }, function (data) {
                var vdata = eval(data);
                if (vdata.success == 1) {
                    messageBox.alert({ content: '保存成功！' });
                } else {
                    messageBox.alert({ content: vdata.msg });
                }
            }, 'json');
        });

        //发送异步请求权限配置数据
        function getauthlist(strArid) {
            var arid = -1;
            if (strArid) {
                arid = strArid.substr(2);
            }

            $.post("{:U('Team/getroleauth_ajax')}", { roleid: arid }, function (data) {
                $('#authconfig').html(data);
            }, 'html');
        }
        //右侧导航条点击响应
        function initNavigationClicks() {
            $(".vertical-navigation li").children("a.tab-link ").off("click").click(function () {
                $('a.tab-link').removeClass('active');
                $(this).addClass('active');

                var strArid = $(this).attr('id');
                getauthlist(strArid);
                return false;
            });
        }

        $(function () {
            $("#btnAddDeptManager").click(function () {
                $("#li_roles_form").animate({ height: "55px", paddingTop: "10px", paddingBottom: "10px" }, 200);
                $("#rolename").focus();
            });

            initNavigationClicks();

            //初始化加载角色权限配置
            /*
            $('.tab-link').first().addClass('active');
            var strArid = $('.roleitem a:first').attr('id');*/
            getauthlist('t_-1');
        });
    });
    </script>
</block>
